package me.hgj.jetpackmvvm.util

import me.hgj.jetpackmvvm.bean.CoachOrderMessageBean


/**
 * @desc
 */
class CoachListenerUtils {

    private val resultList: ArrayList<onCocalListenter> = ArrayList<onCocalListenter>()


    @Volatile
    private var instance: CoachListenerUtils? = null

    private fun CoachListenerUtils() {}

    companion object {
        val instance: CoachListenerUtils by lazy {
            CoachListenerUtils()
        }
    }

    fun addListener(listener: onCocalListenter) {
        if (!resultList.contains(listener)) {
            resultList.add(listener)
        }
    }

    fun removeListener(listener: onCocalListenter) {
        if (resultList.contains(listener)) {
            resultList.remove(listener)
        }
    }

    fun onCallAgree(order_id: String?= "",bean: CoachOrderMessageBean) {
        for (listener in resultList) {
            listener.onCallAgree(order_id,bean)
        }
    }

    fun onCallReject(order_id: String ?= "",bean: CoachOrderMessageBean) {
        for (listener in resultList) {
            listener.onCallReject(order_id,bean)
        }
    }

}